package com.fjd.mapper;

import com.fjd.entity.SearchHistory;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SearchHistoryMapper {

    @Insert("insert into search_history (customer_id, search_record, create_time) VALUES (#{customerId},#{searchRecord},#{createTime})")
    void insert(SearchHistory searchHistory);

    @Select("select search_record from search_history where customer_id = #{id} order by create_time desc")
    List<String> getByCustomerId(String id);

    @Update("update search_history set create_time = #{createTime} where customer_id = #{customerId} and search_record = #{searchRecord}")
    void updateCreateTime(SearchHistory searchHistory);

    @Select("select * from search_history where customer_id = #{customerId} and search_record = #{searchRecord}")
    SearchHistory getByCustomerIdAndSearchRecord(String customerId, String searchRecord);

    @Delete("delete from search_history where customer_id = #{currentId}")
    void deleteByCustomerId(String currentId);
}
